package org.essilab.analyzer.application;

import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import org.essilab.analyzer.Configuration.Config;
import org.essilab.analyzer.analyzer.IArticle;
import org.essilab.analyzer.analyzer.XmlParser;
import org.essilab.analyzer.wikitionary.WikiArticle;

/**
 * This class is used to start the extraction of the Wiktionary XML dump in text
 * files. The XML file path has to be passed in argument.
 *
 * @author Mohamed-Amine Chouchene, Ahcène Idinarere, Vincent Nock, Alain
 * Janin-Manificat
 */
public class Application {

    /**
     * Extract informations from the Wiktionary XML dump and store them in text
     * files.
     */
    public static void main(String[] args) throws FileNotFoundException {
        if (args.length != 1) {
            System.err.println("Usage: Parser <XML-FILE>");
            System.exit(-1);
        }
        PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream("out.err")));
        System.setErr(out);
        Config.setFile("config.ini");
        String bz2Filename = args[0];
        IArticle handler = new WikiArticle();
        try {
            XmlParser wxp = new XmlParser(bz2Filename, handler);
            wxp.parse();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
